<template>
    <div class="views-duihuan-detail">
        <div>
            <el-card class="box-card">
                <template #header>
                    <div class="clearfix">
                        <span class="title"> 兑换详情 </span>
                    </div>
                </template>

                <div id="printdetail">
                    <el-descriptions class="margin-top" :column="3" border>
                        <el-descriptions-item label="商品名称"> {{ map.shangpinmingcheng }} </el-descriptions-item>
                        <el-descriptions-item label="所需积分"> {{ map.suoxujifen }} </el-descriptions-item>
                        <el-descriptions-item label="兑换人">
                            <e-user-info module="yonghu" name="xingming" touxiang="touxiang" username="yonghuming" :value="map.duihuanren">
                                <template #default="{user}">
                                    <div class="user-info-desc">
                                        <span> {{ user.lianxifangshi }} </span>
                                    </div>
                                </template>
                            </e-user-info>
                        </el-descriptions-item>
                        <el-descriptions-item label="添加时间"> {{ map.addtime }} </el-descriptions-item>
                    </el-descriptions>

                    <el-descriptions direction="vertical" class="margin-top" :column="1" border>
                        <el-descriptions-item label="商品图片"> <e-images :src="map.shangpintupian" type="detail"></e-images> </el-descriptions-item>
                        <el-descriptions-item label="备注"> {{ map.beizhu }} </el-descriptions-item>
                    </el-descriptions>
                </div>
                <div class="no-print" v-if="isShowBtn">
                    <el-button @click="$router.go(-1)">返回</el-button>
                    <el-button @click="$print('#printdetail')">打印</el-button>
                </div>
            </el-card>
        </div>
    </div>
</template>

<script setup>
    import http from "@/utils/ajax/http";
    import DB from "@/utils/db";

    import { ref, reactive, watch, computed } from "vue";
    import { useRoute } from "vue-router";
    import { session } from "@/utils/utils";
    import { extend } from "@/utils/extend";
    import { useDuihuanFindById, canDuihuanFindById } from "@/module";

    const route = useRoute();
    const props = defineProps({
        id: {
            type: [Number, String],
        },
        isShowBtn: {
            type: Boolean,
            default: true,
        },
    });

    /**
     * 获取详情页面的一行数据,当url参数id变更时，当url参数id变更时，自动更新map中的数据
     * @type {EDuihuan}
     */
    const map = useDuihuanFindById(props.id);
    watch(
        () => props.id,
        (id) => {
            canDuihuanFindById(id).then((res) => {
                extend(map, res);
            });
        }
    );
    // end 获取详情页面的一行数据
</script>

<style scoped lang="scss">
    .views-duihuan-detail {
    }
</style>
